import Vue from "vue";
import VueRouter from "vue-router";

//引入子路由
import AddList from "@/router/addBook"; //通讯录
import Appointment from "@/router/appointment"; //预约管理
import Business from "@/router/business"; //商业智能
import Checking from "@/router/checking"; //预约管理
import Customer from "@/router/customer"; //客服管理
import Diagnosis from "@/router/diagnosis"; //诊断管理
import Financial from "@/router/financial"; //财务管理
import Medicine from "@/router/medicine"; //药品管理
import Patient from "@/router/patient"; //患者管理
import PubNotice from "@/router/pubNotice"; //公告通知
import Role from "@/router/role"; //角色管理
import Supply from "@/router/supply"; //供应管理
import User from "@/router/user"; //用户管理
import WorkFlow from "@/router/workFlow"; //工作流程
import UserPanel from '@/views/UserPanel';//个人面板


Vue.use(VueRouter);
import Layout from "@/views/Layout";
import Login from "@/views/Login";
import Home from "@/views/Home";


const routes = [
  {
    path: "/",
    name: "Layout",
    component: Layout,
    meta: {
      title: "首页",
    },
    children: [
      {
        path: "/",
        name: "home",
        meta: {
          title: "首页",
        },
        component: Home,
      },
      ...AddList,
      ...Appointment,
      ...Business,
      ...Checking,
      ...Customer,
      ...Diagnosis,
      ...Financial,
      ...Medicine,
      ...Patient,
      ...PubNotice,
      ...Role,
      ...Supply,
      ...User,
      ...WorkFlow,
      {
        path: "/noAccess",
        name: "noAccess",
        component: () =>
          import(/* webpackChunkName: "about" */ "@/components/Error/403.vue"),
        meta: {
          title: "403",
        },  
      },
      {
        path: "/userPanel",
        name: "userPanel",
        component: UserPanel,
      },   
    ],
  },
  {
    path: "/login",
    name: "login",
    component: Login,
  },
 
];



const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
});




const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}



export default router;